Regression for Linguists
  • D. Palleschi
  1. Part I: Foundations
  2. 5  Categorical predictors
  • Overview
    • Course overview
    • Syllabus
    • Resources and Set-up
  • Part I: Foundations
    • 1  Understanding straight lines
    • 2  Simple linear regression
    • 3  Continuous predictors
    • 4  Multiple Regression
    • 5  Categorical predictors
    • 6  Logistic regression
  • Part II: Mixed models
  • Reports

Table of contents

  • Set-up environment
  • 6 Categorical predictors
  • 7 Contrast coding
  • 8 Simple linear regression vs. t-test
  • 9 Summary
    • Important terms
  • 10 Task

5  Categorical predictors

Regression for Linguists

Author
Affiliation

Daniela Palleschi

Humboldt-Universität zu Berlin

Published

October 2, 2023

Learning Objectives

Today we will learn…

Set-up environment

# suppress scientific notation
options(scipen=999)

We’ll also need to load in our required packages. Hopefully you’ve already install the required packages (if not, go to Chapter 3).

# load libraries
pacman::p_load(
               tidyverse,
               here,
               broom,
               lme4,
               janitor,
               languageR)
df_freq <- read_csv(here("data", "ELP_frequency.csv")) |> 
  clean_names()

6 Categorical predictors

7 Contrast coding

8 Simple linear regression vs. t-test

  • simple linear regression is equivalent to a t-test
    • the real power of linear regression is coming up…multiple regression and mixed models
# df_freq %>% 
# t.test(rt ~ lifetime, data = .)
# df_freq %>% 
# lm(rt ~ lifetime, data = .) %>% 
#   tidy() %>%
#   mutate_if(is.numeric, round, 7)

9 Summary

  • we saw that the equation for a straight line boils down to its intercept and slope

  • we fit our first linear model with a categorical predictor

Important terms

term description/other terms

Learning Objectives

Today we learned…

10 Task

Literaturverzeichnis

4  Multiple Regression
6  Logistic regression
Source Code
---
title: "Categorical predictors"
subtitle: "Regression for Linguists"
author: "Daniela Palleschi"
institute: Humboldt-Universität zu Berlin
# footer: "Lecture 1.1 - R und RStudio"
lang: en
date: "`r Sys.Date()`"
format:
  html:
    number-sections: true
    number-depth: 3
    toc: true
    code-overflow: wrap
    code-tools: true
    self-contained: true
bibliography: references.bib
csl: apa.csl
execute:
  eval: true
  echo: true
  message: false
  error: false
  warning: false
  fig-align: "center"
  fig-asp: .618
---

# Learning Objectives {.unnumbered .unlisted}

Today we will learn...


# Set-up environment  {.unnumbered}

```{r}
# suppress scientific notation
options(scipen=999)
```

We'll also need to load in our required packages. Hopefully you've already install the required packages (if not, go to @sec-software).

```{r}
# load libraries
pacman::p_load(
               tidyverse,
               here,
               broom,
               lme4,
               janitor,
               languageR)
```

```{r}
#| echo: false

# extra packages for the lecture notes/slides
pacman::p_load(
               patchwork,
               knitr,
               kableExtra)
```

```{r}
df_freq <- read_csv(here("data", "ELP_frequency.csv")) |> 
  clean_names()
```


# Categorical predictors

# Contrast coding


# Simple linear regression vs. t-test 

- simple linear regression is equivalent to a t-test
  + the *real* power of linear regression is coming up...multiple regression and mixed models

:::: columns
::: {.column width="50%"}
```{r}
# df_freq %>% 
# t.test(rt ~ lifetime, data = .)
```
:::
::: {.column width="50%"}
```{r}
# df_freq %>% 
# lm(rt ~ lifetime, data = .) %>% 
#   tidy() %>%
#   mutate_if(is.numeric, round, 7)
```
:::
::::

# Summary

-   we saw that the equation for a straight line boils down to its intercept and slope

-   we fit our first linear model with a categorical predictor

## Important terms {.unnumbered .smaller}

```{r}
#| echo: false
tribble(
 ~"term", ~"description/other terms",
 
) %>% kable() %>% kable_styling()
```


# Learning Objectives {.unnumbered .unlisted}

Today we learned...


# Task



# Literaturverzeichnis {.unlisted .unnumbered visibility="uncounted"}

::: {#refs custom-style="Bibliography"}
:::